﻿using AppMVVM.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppMVVM.ViewModels
{
    class ArticleListViewModel : ViewModelBase
    {
        private Source _source;
        public Source Source
        {
            get { return _source; }
            set
            {
                if (_source != value)
                {
                    _source = value;
                    OnPropertyChanged("Source");
                }
            }
        }

        public ObservableCollection<Article> Articles
        {
            get { return new ObservableCollection<Article>(Source.Articles);  }
        }

        private static ArticleListViewModel _instance;

        private ArticleListViewModel()
        {
        }

        public static ArticleListViewModel Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new ArticleListViewModel();
                }
                return _instance;
            }
        }
    }
}
